﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

using Anaida;

namespace AnaidaTest
{
    class Program : IWebSocketListener
    {
        private WebSocketAdapter adapter = null;

        public Program()
        {
            adapter = new WebSocketAdapter("localhost", 4530, "/websocket", this);

        }



        
        public void Onclose()
        {
            Console.Out.WriteLine("WebSocket Closed");

        }


        public void Onmessage(byte[] message)
        {//UTF-8 Charset Encoded String
            Console.Out.WriteLine("Message:" + Encoding.UTF8.GetString(message));
        }



        public void Onopen()
        {
            Console.Out.WriteLine("WebSocket Opened");
            try
            {
                adapter.Send(Encoding.UTF8.GetBytes("Hello World!"), true);
            }
            catch (Exception e)
            {
                Console.Out.WriteLine("Error on open");
            }
        }
    
        static void Main(string[] args)
        {
            Program test = new Program();
            Thread.Sleep(20000);
        }
    }
}
